package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Bangzhuzhongxin;
import com.ruoyi.system.service.IBangzhuzhongxinService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 帮助中心Controller
 * 
 * @author cjq
 * @date 2024-08-13
 */
@RestController
@RequestMapping("/system/bangzhuzhongxin")
public class BangzhuzhongxinController extends BaseController
{
    @Autowired
    private IBangzhuzhongxinService bangzhuzhongxinService;

    /**
     * 查询帮助中心列表
     */
    @PreAuthorize("@ss.hasPermi('system:bangzhuzhongxin:list')")
    @GetMapping("/list")
    public TableDataInfo list(Bangzhuzhongxin bangzhuzhongxin)
    {
        startPage();
        List<Bangzhuzhongxin> list = bangzhuzhongxinService.selectBangzhuzhongxinList(bangzhuzhongxin);
        return getDataTable(list);
    }

    /**
     * 导出帮助中心列表
     */
    @PreAuthorize("@ss.hasPermi('system:bangzhuzhongxin:export')")
    @Log(title = "帮助中心", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Bangzhuzhongxin bangzhuzhongxin)
    {
        List<Bangzhuzhongxin> list = bangzhuzhongxinService.selectBangzhuzhongxinList(bangzhuzhongxin);
        ExcelUtil<Bangzhuzhongxin> util = new ExcelUtil<Bangzhuzhongxin>(Bangzhuzhongxin.class);
        util.exportExcel(response, list, "帮助中心数据");
    }

    /**
     * 获取帮助中心详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:bangzhuzhongxin:query')")
    @GetMapping(value = "/{bzzxId}")
    public AjaxResult getInfo(@PathVariable("bzzxId") Long bzzxId)
    {
        return success(bangzhuzhongxinService.selectBangzhuzhongxinByBzzxId(bzzxId));
    }

    /**
     * 新增帮助中心
     */
    @PreAuthorize("@ss.hasPermi('system:bangzhuzhongxin:add')")
    @Log(title = "帮助中心", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Bangzhuzhongxin bangzhuzhongxin)
    {
        return toAjax(bangzhuzhongxinService.insertBangzhuzhongxin(bangzhuzhongxin));
    }

    /**
     * 修改帮助中心
     */
    @PreAuthorize("@ss.hasPermi('system:bangzhuzhongxin:edit')")
    @Log(title = "帮助中心", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Bangzhuzhongxin bangzhuzhongxin)
    {
        return toAjax(bangzhuzhongxinService.updateBangzhuzhongxin(bangzhuzhongxin));
    }

    /**
     * 删除帮助中心
     */
    @PreAuthorize("@ss.hasPermi('system:bangzhuzhongxin:remove')")
    @Log(title = "帮助中心", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bzzxIds}")
    public AjaxResult remove(@PathVariable Long[] bzzxIds)
    {
        return toAjax(bangzhuzhongxinService.deleteBangzhuzhongxinByBzzxIds(bzzxIds));
    }
}
